<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 对象的属性和方法
      const counter = {};
      counter.count = 0;
      counter.set = function (v) {
        this.count = v;
      };
      counter.decrease = function (v) {
        this.count -= v;
      };

      counter.set(100);
      console.log(counter.count); //100
      counter.decrease(20);
      console.log(counter.count); //80
    </script>
  </body>
</html>
